package kr.pe.johnkim.carrotpoint.mobile.dao;

import kr.pe.johnkim.carrotpoint.mobile.domain.CarrotPointCertification;
import org.mybatis.spring.support.SqlSessionDaoSupport;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;

/**
 * Carrot Point 인증 관련 dao 클래스 이다.
 *
 * @author : John_Kim <cale9797@gmail.com>
 * @date : 13. 2. 6.
 */
@Repository
public class CarrotPointCertificationDaoImpl extends SqlSessionDaoSupport implements CarrotPointCertificationDao {

    // SLF4J Logging
    private Logger logger = LoggerFactory.getLogger(CarrotPointCertificationDaoImpl.class);

    /**
     * 인증 번호를 등록 한다.
     *
     * @param carrotPointCertification
     */
    @Override
    public void registerCertification(CarrotPointCertification carrotPointCertification) {
        logger.info("registerCertification");
        this.getSqlSession().insert("CARROTPOINT_CERTIFICATION.registerCertification", carrotPointCertification);
    }

    /**
     * 해당 사용자의 인증 정보가 있는지 확인 한다.
     *
     * @param carrotPointCertification
     * @return
     */
    @Override
    public CarrotPointCertification getExistCertificationInformation(CarrotPointCertification carrotPointCertification) {
        logger.info("getExistCertificationInformation");
        return (CarrotPointCertification)getSqlSession().selectOne("CARROTPOINT_CERTIFICATION.getExistCertificationInformation", carrotPointCertification);
    }

    /**
     * 해당 사용자의 인증 정보를 가져 온다.
     *
     * @param carrotPointCertification
     * @return
     */
    @Override
    public CarrotPointCertification getCertificationInformation(CarrotPointCertification carrotPointCertification) {
        logger.info("getCertificationInformation");
        return (CarrotPointCertification)getSqlSession().selectOne("CARROTPOINT_CERTIFICATION.getCertificationInformation", carrotPointCertification);
    }

    /**
     * 해당 인증 번호를 비활성화 한다.
     *
     * @param carrotPointCertification
     */
    @Override
    public void updateDeactivateCertification(CarrotPointCertification carrotPointCertification) {
        logger.info("updateDeactivateCertification");
        this.getSqlSession().update("CARROTPOINT_CERTIFICATION.updateDeactivateCertification", carrotPointCertification);
    }
}
